package com.aaa.tmr.controller;

import com.aaa.tmr.entity.User;
import com.aaa.tmr.service.MenuService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("backIndex")
public class BackIndexController {

    @Resource
    private MenuService menuService;

    /**
     * 跳到后台首页
     * @return
     */
    @RequestMapping("toIndex")
    public String toIndex(HttpSession session, Model model){
        User user = (User) session.getAttribute("userInfo");
        model.addAttribute("menuListByUid",menuService.queryByUid(user==null?0:user.getUserId()));
        model.addAttribute("username",user.getUserName());
        return "back/index";
    }
}
